<?php
/**
 * Created by PhpStorm.
 * User: xlosy
 * Date: 2018/4/15
 * Time: 22:24
 */

namespace app\index\model;
use think\Model;

/**
 * 用户模型
 * Class User
 * @package app\manager\model
 */
class User extends Model
{
    //自定义初始化
    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        //TODO:自定义的初始化
    }

    /**
     * @return false|int|void
     */
    public function addUser(){
        $user = new User($_POST);
        $user->id = create_uuid();
        $user->isManager = 0;
        $now = date('Y-m-d H:i:s');
        $user->createDate = $now;
        $user->expireDate = date('Y-m-d H:i:s',strtotime("+1 month"));
        $user->isVip = 1;
        $user->userPasswd = md5(input('userPasswd'));
        $rtn = $user->allowField(true)->save();
        if($rtn){
            session('uid',$user);
        }
        return $rtn;
    }
}